<script language="javascript" type="text/javascript">   
Joomla.submitform = function(pressbutton) {
	if (pressbutton != 'toExcel' && pressbutton != 'toPDF') {
		var form = document.adminForm;
		form.task.value = '';			
	}
		
	submitform(pressbutton);
};
</script>

<form action="" method="post" name="adminForm">
<?php $role_pim =  ManagerHelper::getRolePim();
	if($role_pim->add == 1 || $role_pim == -1){ 
?>
	<table class="adminform">
		<tr>
            <td width="10%" >
	            <label for="Code">
	                <?php echo JText::_( 'Pond Name' ); ?>
	            </label>
	        </td>
	        <td width="40%">
	        	<?php echo $this->lists['pond_code'] ; ?>
	        </td>  
	        <td width="10%" >
	            <label for="Code">
	                <?php echo JText::_( 'Serial Code' ); ?>
	            </label>
	        </td>
	        <td width="40%" id="list_area">
	        	<?php echo $this->lists['serial_code'] ; ?>
	        </td>            
	    </tr>

		<tr>
	        <td width="10%" >
	            <label for="Code">
	                <?php echo JText::_( 'Fish Class Name' ); ?>
	            </label>
	        </td>
	        <td width="40%">
	        	<?php echo $this->lists['class_code'] ; ?>
	        </td>
	        <td width="10%" >
	            <label for="Code">
	                <?php echo JText::_( 'Customer Name' ); ?>
	            </label>
	        </td>
	        <td width="40%">
	        	<?php echo $this->lists['customer_code'] ; ?>
	        	<a href="<?php echo JRoute::_('index.php?option=com_manager&c=product&task=add_popup&tmpl=component')?>" class="modal" rel="{handler: 'iframe', size: {x: 575, y: 300}}"><img src="<?php echo JURI::root().'administrator/templates/bluestork/images/admin/icon-16-add.png'?>" title="Add New Customer" style="position:relative; top:4px;" /></a>
	        </td>  
	    </tr>
	    
	    <tr>
	    	<td width="10%" >
	            <label for="feed_date">
	                <?php echo JText::_( 'Feed Date' ); ?>
	            </label>
	        </td>
	        <td width="40%">
	        	<?php echo JHtml::calendar(date('d-m-Y'), 'feed_date', 'feed_date', '%d-%m-%Y', array('readonly'=>''));?>
	        </td>
	        <td width="10%" >
	            <label for="status">
	                <?php echo JText::_( 'Status' ); ?>
	            </label>
	        </td>
	        <td width="40%">
	        	<?php echo $this->lists['status'] ; ?>
	        </td> 
	    </tr>
	    
	    <tr>
	    	<td width="10%" >
	            <label for="sale_date">
	                <?php echo JText::_( 'Sale Date' ); ?>
	            </label>
	        </td>
	        <td width="40%">
	        	<?php echo JHtml::calendar(date('d-m-Y'), 'sale_date', 'sale_date', '%d-%m-%Y', array('readonly'=>''));?>
	        </td>
	    </tr>
	    
	    <tr>
	    	<td colspan="4" style="text-align:center">
	    		<button type="submit" name="add_button" value="add" onclick="Joomla.submitbutton('view')">Add New</button>
	    	</td>
	    </tr>
	</table>
<?php } ?>	
	<fieldset id="filter-bar">
		<div class="filter-search fltlft">
			<label class="filter-search-lbl" for="filter_search"><?php echo JText::_('Serial Code'); ?></label>
			<input type="text" name="filter_serial" id="filter_serial" value="<?php echo $this->filter_serial?>" />
			
			<select name="filter_pond" class="inputbox">
				<option value=""><?php echo JText::_(ManagerHelper::SELECT_POND);?></option>
				<?php echo JHtml::_('select.options', $this->arr_pond, 'id', 'name', $this->filter_pond);?>
			</select>
			
			<select name="filter_fishclass" class="inputbox">
				<option value=""><?php echo JText::_(ManagerHelper::SELECT_FISH_CLASS);?></option>
				<?php echo JHtml::_('select.options', $this->arr_fishclass, 'id', 'name', $this->filter_fishclass);?>
			</select>
			
			<select name="filter_customer" class="inputbox">
				<option value=""><?php echo JText::_(ManagerHelper::SELECT_CUSTOMER);?></option>
				<?php echo JHtml::_('select.options', $this->arr_customer, 'id', 'name', $this->filter_customer);?>
			</select>
			
			<select name="filter_status" class="inputbox">
				<option value="-1"><?php echo JText::_(ManagerHelper::SELECT_STATUS);?></option>
				<?php echo JHtml::_('select.options', $this->arr_status, 'id', 'name', $this->filter_status);?>
			</select>

			<button type="submit" name="filter_button" value="filter" onclick="Joomla.submitbutton('view')"><?php echo JText::_('JSEARCH_FILTER_SUBMIT'); ?></button>
		</div>
		<div class="filter-select fltrt">             
		</div>
	</fieldset>
	
	<table class="adminlist">
		<thead>	
			<tr>
				<th width="5%">
					<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo $this->TOTAL_ROW;?>);" />
				</th>
				<th class="title" width="10%">
					<?php echo JHtml::_('grid.sort', 'Product ID', 'p.id', $this->FORM_ORDER_DIR, $this->FORM_ORDER); ?>
				</th>	
				<th class="title" width="10%">
					<?php echo JHtml::_('grid.sort', 'Serial Code', 'p.serial_code', $this->FORM_ORDER_DIR, $this->FORM_ORDER); ?>
				</th>					
				<th class="title" width="10%" >
					 <?php echo JHtml::_('grid.sort', 'Pond Name', 'po_name', $this->FORM_ORDER_DIR, $this->FORM_ORDER); ?>
				</th>			
				<th class="title" width="15%">
					<?php echo JHtml::_('grid.sort', 'Fish Class Name', 'fc_name', $this->FORM_ORDER_DIR, $this->FORM_ORDER); ?>
				</th>
				<th class="title" width="15%">
					<?php echo JHtml::_('grid.sort', 'Customer Name', 'cu_name', $this->FORM_ORDER_DIR, $this->FORM_ORDER); ?>
				</th>
				<th class="title" width="10%">
					<?php echo JHtml::_('grid.sort', 'Feed Date', 'p.feed_date', $this->FORM_ORDER_DIR, $this->FORM_ORDER); ?>
				</th>
				<th class="title" width="10%">
					<?php echo JHtml::_('grid.sort', 'Sale Date', 'p.sale_date', $this->FORM_ORDER_DIR, $this->FORM_ORDER); ?>
				</th>
				<th class="title" width="10%">
					<?php echo JHtml::_('grid.sort', 'Expired Date', 'p.expired_date', $this->FORM_ORDER_DIR, $this->FORM_ORDER); ?>
				</th>
				<th class="title" width="10%">
					 Status
				</th>
			</tr>
		</thead>
		<tfoot>
			<tr>
				<td colspan="14">
					<?php echo $this->LIST_FOOTER_PAV;?>
				</td>
			</tr>
		</tfoot>
		<tbody>
			<?php if($this->TOTAL_ROW && is_array($this->dbrow)) {
					$i = 0;
					foreach($this->dbrow as $key=>$value) {
					 	$checked = JHTML::_('grid.checkedout', $value, $i );
					 	$css_row = $i%2 ? 'row0':'row1'; 
			?>
						<tr class="<?=$css_row?>">
							<td align="center"><?php echo $checked;?></td>
							<td align="center">
								<a href="<?php echo JRoute::_('index.php?option=com_manager&c=product&task=edit&cid[]='.$value->id)?>" title="<?php echo $value->id;?>">
									<?php echo $value->id;?>
								</a>
							</td>
							<td align="center">
								<a href="<?php echo JRoute::_('index.php?option=com_manager&task=edit&cid[]='.$value->se_id)?>" title="<?php echo $value->se_code;?>">
									<?php echo $value->se_code;?>
								</a>
							</td>
							<td align="center">
								<a href="<?php echo JRoute::_('index.php?option=com_manager&c=pond&task=edit&cid[]='.$value->po_id)?>" title="<?php echo $value->po_name;?>">
									<?php echo $value->po_name;?>
								</a>
							</td>
							<td align="center">
								<a href="<?php echo JRoute::_('index.php?option=com_manager&c=fishclass&task=edit&cid[]='.$value->fc_id)?>" title="<?php echo $value->fc_name;?>">
									<?php echo $value->fc_name;?>
								</a>
							</td>
							<td align="center">
								<a href="<?php echo JRoute::_('index.php?option=com_manager&c=customer&task=edit&cid[]='.$value->cu_id)?>" title="<?php echo $value->cu_name;?>">
									<?php echo $value->cu_name;?>
								</a>
							</td>
							<td align="center">
								<?php if (empty($value->feed_date))  echo ''; else echo ManagerHelper::formatDate($value->feed_date);?>
							</td>
							<td align="center">
								<?php if (empty($value->sale_date))  echo ''; else echo ManagerHelper::formatDate($value->sale_date);?>
							</td>
							<td align="center">
								<?php if (empty($value->expired_date))  echo ''; else echo ManagerHelper::formatDate($value->expired_date);?>
							</td>
							<td align="center">
								<?php echo (ManagerHelper::getTextStatus($value->status)); ?>
							</td>	
						</tr>
			<?php
						$i++;
					 }
				} 
			 ?>	
		</tbody>
	</table>
			
	<input type="hidden" name="option" value="com_manager" />
	<input type="hidden" name="c" value="product" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="boxchecked" value="0" />
	<input type="hidden" name="filter_order" value="<?php echo $this->FORM_ORDER;?>" />
	<input type="hidden" name="filter_order_Dir" value="<?php echo $this->FORM_ORDER_DIR;?>" />
	<?php echo $this->FORM_TOKEN;?>
</form>
